# Maintainer: Celeste <cielesti@protonmail.com>
maintainer="Celeste <cielesti@protonmail.com>"
pkgname=rebar3
pkgver=3.24.0
pkgrel=0
pkgdesc="Erlang build tool"
url="https://github.com/erlang/rebar3"
arch="noarch"
license="Apache-2.0"
depends="erlang"
makedepends="
	erlang-dev
	erlang-dialyzer
	"
subpackages="
	$pkgname-doc
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/erlang/rebar3/archive/refs/tags/$pkgver.tar.gz"
options="net" # needed to get a package index and the test depends, like npm

prepare() {
	default_prepare

	# chosen by fair dice roll
	mkdir -p /tmp/secret-rebar-temp-4
}

build() {
	DEBUG=1 HOME="/tmp/secret-rebar-temp-4" ./bootstrap --offline
}

check() {
	HOME="/tmp/secret-rebar-temp-4" ./rebar3 ct
}

package() {
	install -Dm755 rebar3 -t "$pkgdir"/usr/bin/
	install -Dm644 manpages/rebar3.1 -t "$pkgdir"/usr/share/man/man1/

	install -Dm644 apps/rebar/priv/shell-completion/bash/rebar3 \
		-t "$pkgdir"/usr/share/bash-completion/completions/
	install -Dm644 apps/rebar/priv/shell-completion/fish/rebar3.fish \
		-t "$pkgdir"/usr/share/fish/vendor_completions.d/
	install -Dm644 apps/rebar/priv/shell-completion/zsh/_rebar3 \
		-t "$pkgdir"/usr/share/zsh/site-functions/
}

sha512sums="
f6673d384e9f16b27e940ee738b15088007c1edd4b8cc87e4624ba66aead9fbe790f39797abd3996f4e234ca3536d4d0b9e4166bec6df21ec2ea887cfabcb2a6  rebar3-3.24.0.tar.gz
"
